package ezonsport.android.ui;


import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;
import ezonsport.android.R;
import ezonsport.android.application.PreferenceKeys;

/**
 * 
 * @author ll
 * 用户个人信息页面
 *
 */
public class InformationActivity extends Activity {
	private TextView mUserName;
	private TextView mUserGender;
	private TextView mUserHeight;
	private TextView mUserWeight;
	private TextView mUserBirthday;
	private SharedPreferences mSharedPre;
	private int mYear;
	private int mMonth;
	private int mDay;
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.information);
        
        mUserName = (TextView)findViewById(R.id.information_tx_profile);
        mUserGender = (TextView)findViewById(R.id.information_tx_user_gender);
        mUserHeight = (TextView)findViewById(R.id.information_tx_user_height);
        mUserWeight = (TextView)findViewById(R.id.information_tx_user_weight);
        mUserBirthday = (TextView)findViewById(R.id.information_tx_user_birthday);
        mSharedPre = getSharedPreferences(PreferenceKeys.SHAREPREFERENCENAME, MODE_PRIVATE);
        
        
    }
    @Override
    protected void onResume(){
    	super.onResume();
    	initInformation(); 	
    }
    //未完全
    private void initInformation(){
    	mUserGender.setText(mSharedPre.getString(PreferenceKeys.USER_GENDER, ""));
    	mUserHeight.setText(mSharedPre.getString(PreferenceKeys.USER_HEIGHT, ""));
    	mUserWeight.setText(mSharedPre.getString(PreferenceKeys.USER_WEIGHT, ""));
    	mYear = mSharedPre.getInt(PreferenceKeys.USER_BIRTHDAY_YEAR, 0);
        mMonth = mSharedPre.getInt(PreferenceKeys.USER_BIRTHDAY_MONTH, -1);
        mDay = mSharedPre.getInt(PreferenceKeys.USER_BIRTHDAY_DAY, 0);
        if((mYear!=0)&&(mMonth!=-1)&&(mDay!=0)){
        	mUserBirthday.setText(String.valueOf(mYear)+"-"+String.valueOf(mMonth+1)+
    				"-" + String.valueOf(mDay));
    	}else
    		mUserBirthday.setText("");
    }

}
